module.exports = class R {
  constructor(code = -1, message = '', type = 'success', data = null) {
    this.code = code;
    this.message = message;
    this.type = type;
    this.data = data;
  }

  static ok(data, message = '获取成功') {
    return new R(0, message, 'success', data);
  }

  static okMsg(...message) {
    return new R(0, [...message].join(''), 'success');
  }

  static errMsg(...message) {
    return new R(-1, [...message].join(''), 'error');
  }
}